# -*- coding: utf-8 -*-
# @Time        :2025/4/17 10:01
# @Author      :文刀水寿
# @File        : app.py
"""
 @Description :
"""
from fastapi import FastAPI, Request
import uvicorn
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

origins = [
    "http://localhost:8080"
]


@app.middleware("http")
async def MyCORSmideele(request: Request, call_next):
    response = await call_next(request)
    response.headers["Access-Control-Allow-Origin"] = "*"
    return response


app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["GET"],
    allow_headers=["*"]
)


@app.get("/")
async def middle2():
    return {"user": "current user"}


if __name__ == '__main__':
    uvicorn.run("main:app",
                reload=True,
                port=8080)
